import {
  q as s,
  p as M,
  ap as R,
  X as m,
  f as T,
  H as A,
  av as y,
  aw as O,
  k as v,
  m as b,
  l as x,
  az as E,
  as as n,
  aG as F,
  at as h
} from "./index-30f27935.js";
import { f as w } from "./finance-301595de.js";
function q(W) {
  const c = s([]),
    a = s(!0);
  s({}), M();
  const g = s(1),
    d = s(10),
    B = R("reload"),
    u = m({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    C = m({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    _ = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "id", minWidth: 50 },
      { label: "ID", prop: "user_id", minWidth: 50 },
      { label: "用户名", prop: "user_name", minWidth: 80 },
      { label: "手机号", prop: "user_phone", minWidth: 100 },
      {
        label: "修改前门店码",
        prop: "old_code",
        minWidth: 100,
        formatter: ({ old_code: e }) =>
          e ||
          v(
            x("el-tag"),
            { class: "mx-1", type: "info", effect: "light" },
            { default: () => [b("暂无")] }
          )
      },
      {
        label: "修改前名称",
        prop: "old_name",
        minWidth: 100,
        formatter: ({ old_name: e }) =>
          e ||
          v(
            x("el-tag"),
            { class: "mx-1", type: "info", effect: "light" },
            { default: () => [b("暂无")] }
          )
      },
      { label: "修改后门店码", prop: "new_code", minWidth: 100 },
      { label: "修改后名称", prop: "new_name", minWidth: 100 },
      { label: "备注", prop: "content", minWidth: 80 },
      { label: "创建时间", prop: "create_time", minWidth: 100 }
    ],
    S = T(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function I(e) {
    E(e);
  }
  async function J(e) {
    const o = { role_id: e.role_id },
      r = JSON.stringify(o),
      l = { value: n.enc.Base64.stringify(n.enc.Utf8.parse(r)) },
      t = await F(l);
    t.code == 200
      ? (h("删除成功", { type: "success" }), B())
      : h(t.msg, { type: "error" });
  }
  function k() {}
  function z(e) {
    (d.value = e), p(void 0, e);
  }
  function U(e) {
    (g.value = e), p(e, void 0);
  }
  function D(e) {}
  function L(e) {
    (C.text = `正在加载第${e}页...`),
      (a.value = !0),
      y(600).then(() => {
        a.value = !1;
      });
  }
  async function N(e) {
    a.value = !0;
    const o = {
        page: 1,
        pagesize: d.value,
        content: "store",
        user_phone: e.user_phone,
        type: e.type
      },
      r = JSON.stringify(o),
      l = { value: n.enc.Base64.stringify(n.enc.Utf8.parse(r)) },
      { data: t } = await w(l);
    (c.value = t.store.data),
      (u.total = t.store.total),
      setTimeout(() => {
        a.value = !1;
      }, 500);
  }
  async function p(e = g.value, o = d.value) {
    const f = JSON.stringify({ page: e, pagesize: o, content: "store" }),
      t = { value: n.enc.Base64.stringify(n.enc.Utf8.parse(f)) },
      i = await w(t);
    i.code === 200
      ? ((c.value = i.data.store.data),
        (u.total = i.data.store.total),
        setTimeout(() => {
          a.value = !1;
        }, 500))
      : h(i.msg, { type: "error" });
  }
  const V = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    A(() => {
      y().then(() => {
        const { setWatermark: e } = O(W.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        p();
    }),
    {
      loading: a,
      columns: _,
      dataList: c,
      pagination: u,
      buttonClass: S,
      onSearch: N,
      resetForm: V,
      handleaddUser: k,
      handleUpdate: I,
      handleDelete: J,
      handleSizeChange: z,
      handleCurrentChange: U,
      handleSelectionChange: D,
      onCurrentChange: L
    }
  );
}
export { q as useRole };
